package com.nbsaas.boot.trade.rest.convert;

import com.nbsaas.boot.trade.data.entity.TradeInfo;
import com.nbsaas.boot.trade.api.domain.request.TradeInfoRequest;

import org.springframework.beans.BeanUtils;
import com.nbsaas.boot.rest.api.Converter;
import com.nbsaas.boot.utils.BeanDataUtils;
            import com.nbsaas.boot.trade.data.entity.TradeAccount;
            import com.nbsaas.boot.trade.data.entity.TradeAccount;

/**
* 交易单请求对象转换成实体对象
*/

public class TradeInfoEntityConvert  implements Converter<TradeInfo, TradeInfoRequest> {

    @Override
    public TradeInfo convert(TradeInfoRequest source) {
        TradeInfo result = new TradeInfo();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getFrom()!=null){
                    TradeAccount from =new TradeAccount();
                    from.setId(source.getFrom());
                    result.setFrom(from);
                    }
                    if(source.getTo()!=null){
                    TradeAccount to =new TradeAccount();
                    to.setId(source.getTo());
                    result.setTo(to);
                    }
        return result;
    }
}

